package kr.hikt.androidcomplete01.ch07;

import kr.hikt.androidcomplete01.R;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;

public class DrawBitmap extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new MyView(this));
	}

	class MyView extends View {
		private Paint paint;
//		private Resources res;
//		private BitmapDrawable bd;
		private Bitmap bit;
		
		public MyView(Context context) {
			super(context);
			paint = new Paint();
//			res = getResources();
//			bd = (BitmapDrawable) res.getDrawable(R.drawable.harubang);
//			bit = bd.getBitmap();
			bit = BitmapFactory.decodeResource(getResources(), R.drawable.harubang);
		}

		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			canvas.drawColor(Color.LTGRAY);
			
			canvas.drawBitmap(bit, 10, 10, null);
			canvas.drawBitmap(bit, null, new Rect(120, 10, 170, 85), null);
			canvas.drawBitmap(bit, new Rect(30, 30, 70, 80), new Rect(180, 10, 180+80, 10+100), null);
		}
	}
}
